基于zDialog改造的弹出框控件,其特点如下:
1、对于新建、编辑、浏览框均可使用该组件实现;
2、可以自定义弹出框的大小;
3、可以实现URL和非URL两种形式的页面;
4、可以设定是否允许最大化窗口;
5、可以设定是否检测页面内容的改变提醒;
在页面中引用以下代码
<script language="javascript" src="/wui/theme/ecology8/jquery/js/zDialog_wev8.js"></script>
参考代码
<script language="javascript" type="text/javascript">
//在其子页面中,调用此方法打开相应的界面
function openDialog(title,url) {
var dlg=new window.top.Dialog();//定义Dialog对象
dialog.currentWindow = window;
dlg.Model=true;
dlg.Width=500;//定义长度
dlg.Height=400;
dlg.URL=url;
dlg.Title=title;
dlg.show();
}
</script>
-
在弹出框获取相关对象
//在被打开的页面中,使用如下语句获取父窗口对象: parentWin
= parent.getParentWindow(window);
//在被打开的页面中,使用如下语句获取Dialog对象: dialog
= parent.getDialog(window);
基于分页控件的示例代码整理。父页面打开弹窗代码
function newDialog(){
openDialog("新建数据","/demo/demo_dialog1.jsp");
}
function openDialog(title, url) {
var dlg = new window.top.Dialog(); //定义Dialog对象
dlg.currentWindow = window;
dlg.Model = false;
dlg.Width = 1060; //定义长度
dlg.Height = 500;
dlg.URL = url;
dlg.Title = title ;
dlg.maxiumnable = true;
dlg.show();
window.dialog = dlg;
}
-
弹出窗口代码:
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%>
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page" />
<%@ include file="/systeminfo/init_wev8.jsp" %>
<HTML><HEAD>
<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
<script type='text/javascript' src='/js/jquery-autocomplete/lib/jquery.bgiframe.min_wev8.js'></script>
<script type='text/javascript' src='/js/jquery-autocomplete/jquery.autocomplete_wev8.js'></script>
<script type='text/javascript' src='/js/jquery-autocomplete/browser_wev8.js'></script>
<link rel="stylesheet" type="text/css" href="/js/jquery-autocomplete/jquery.autocomplete_wev8.css" />
<link rel="stylesheet" type="text/css" href="/js/jquery-autocomplete/browser_wev8.css" />
</HEAD>
<body scroll="no">
<jsp:include page="/systeminfo/commonTabHead.jsp">
<jsp:param name="mouldID" value="blog"/>
<jsp:param name="navName" value="这里是弹出框打开的页面" />
</jsp:include>
<wea:layout type="fourCol">
<wea:group context="常用条件">
<wea:item>流程</wea:item>
<wea:item>
<brow:browser name="workflowid" viewType="0" hasBrowser="true" hasAdd="false"
browserUrl="/systeminfo/BrowserMain.jsp?url=/workflow/workflow/WorkflowBrowser_frm.jsp?isTemplate=0&iswfec=1"
isMustInput="1" isSingle="true" hasInput="true"
completeUrl="/data.jsp?type=workflowBrowser&isTemplate=0"
width="300px" browserValue="" browserSpanValue="" />
</wea:item>
<wea:item>人员</wea:item>
<wea:item>
<brow:browser name="userid" viewType="0" hasBrowser="true" hasAdd="false"
browserUrl='<%="/systeminfo/BrowserMain.jsp?url=/hrm/resource/MutiResourceBrowser.jsp" %>'
isMustInput="2"
isSingle="false"
hasInput="true"
completeUrl="/data.jsp?type=1" width="300px"
browserValue=''
browserSpanValue=''
/>
</wea:item>
</wea:group>
</wea:layout>
<!-- 添加弹出窗口底部的操作按钮,样式和ID必须固定 -->
<div id="zDialog_div_bottom" class="zDialog_div_bottom">
<table width="100%">
<tr><td style="text-align:center;">
<input type="button" value="<%=SystemEnv.getHtmlLabelName(725,user.getLanguage()) %>" id="zd_btn_submit" class="zd_btn_submit" onclick="javascript:doSave(this)">
<span class="e8_sep_line">|</span>
<input type="button" value="<%=SystemEnv.getHtmlLabelName(309,user.getLanguage())%>" id="zd_btn_cancle" class="zd_btn_cancle" onclick="clostWin();">
</td></tr>
</table>
</div>
<!-- 定义和显示右上角的菜单,id和样式固定不能随便修改。td里面的内容为显示的操作按钮 -->
<table id="topTitle" cellpadding="0" cellspacing="0">
<tr>
<td class="rightSearchSpan" style="text-align:right;" >
<input type="button" value="<%=SystemEnv.getHtmlLabelName(725,user.getLanguage()) %>" class="e8_btn_top" onclick="javascript:doSave(this)">
<span title="<%=SystemEnv.getHtmlLabelName(83721,user.getLanguage())%>" class="cornerMenu" id="rightclickcornerMenu">
</span>
</td>
</tr>
</table>
<script type="text/javascript">
var pdialog = parent.getDialog(window);//获取窗口对象;
var parentWin = parent.getParentWindow(window);//获取父对象;
function clostWin(){
pdialog.close();
}
function doSave(){
alert("保存数据");//假设数据保存成功,刷新父窗口,关闭弹窗
parentWin.location.reload();
pdialog.close();
}
</script>
</body>
</html>
-
效果图如下: